<div class="flexform">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'product-skill-level-form',
        'enableAjaxValidation' => false
            ));
    ?>
    <div class="row">
        <label>游戏</label>
        <div><?php echo CHtml::dropDownList('game', '', array('' => '') + ProductCategory::model()->getGameSelect(), array('onchange' => 'getSkill(this)'))?></div>
    </div>
    <div class="row">
        <?php echo $form->labelEx($model, 'skill_id'); ?>
        <?php echo $form->dropDownList($model, 'skill_id', array('' => '--')); ?>
        <?php echo $form->error($model, 'skill_id', array('class' => 'form-msg-error-advanced')); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'skill_level'); ?>
        <?php echo $form->textField($model, 'skill_level', array('size' => 11, 'maxlength' => 11)); ?>
        <?php echo $form->error($model, 'skill_level', array('class' => 'form-msg-error-advanced')); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'skill_time'); ?>
        <?php echo $form->textField($model, 'skill_time', array('size' => 10, 'maxlength' => 10)); ?>
        <?php echo $form->error($model, 'skill_time', array('class' => 'form-msg-error-advanced')); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'skill_price'); ?>
        <?php echo $form->textField($model, 'skill_price', array('size' => 12, 'maxlength' => 12)); ?>
        <?php echo $form->error($model, 'skill_price', array('class' => 'form-msg-error-advanced')); ?>
    </div>

    <div class="action">
        <?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
    </div>
    <?php $this->endWidget(); ?>
</div><!-- form -->
<div class="clear"></div>
<script>
    function getSkill(obj){
        $.post("<?php echo $this->createUrl('productSkill/ajax');?>", {game:$(obj).val()}, function(data){
            if(data){
                $("#ProductSkillLevel_skill_id option").remove();
                $.each(data, function(i, n){
                    $("#ProductSkillLevel_skill_id").append('<option value="'+i+'">'+n+'</option>');
                });
            }
        }, "json");
    }
</script>